package com.ltsh.fim.common.model;


import com.alibaba.fastjson.JSONObject;

import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

public class FimRequest {
    protected static AtomicLong atomicLong = new AtomicLong();
    private long id;
    private byte type;
    private byte[] data;

    public FimRequest() {
        this.id = atomicLong.getAndIncrement();
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }


    public Map<String, Object> getMap() {
        byte[] data = this.getData();
        if(data != null) {
            return JSONObject.parseObject(data, Map.class);
        }
        return null;
    }
    public <T> T toBean(Class<T> tClass) {
        byte[] data = this.getData();
        if(data != null) {
            return JSONObject.parseObject(data, tClass);
        }
        return null;
    }
}
